package com.easemob.easeui.widget.chatrow;

import android.content.Context;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.easemob.chat.EMMessage;
import com.easemob.easeui.EaseConstant;
import com.easemob.easeui.R;

public class EaseChatRowPresent extends EaseChatRowText {
	protected TextView presentCountView;
	protected ImageView presentIconView;

    public EaseChatRowPresent(Context context, EMMessage message, int position, BaseAdapter adapter) {
		super(context, message, position, adapter);
	}

	@Override
	protected void onInflatView() {
	    inflater.inflate(message.direct == EMMessage.Direct.RECEIVE ? 
	            R.layout.ease_row_receive_present: R.layout.ease_row_sent_present, this);
	}

	@Override
	protected void onFindViewById() {
		presentCountView = (TextView) findViewById(R.id.tv_chatcontent);
		presentIconView = (ImageView) findViewById(R.id.img_present_icon);
	}

	@Override
	public void onSetUpView() {
		String countStr = message.getStringAttribute(EaseConstant.MESSAGE_PRESENT_COUNT, null);
		presentCountView.setText(countStr+"");
		String typeStr = message.getStringAttribute(EaseConstant.MESSAGE_PRESENT_TYPE, null);
		int viewType = Integer.parseInt(typeStr);
		if(viewType == 1){
			presentIconView.setImageResource(R.drawable.icon_chat_money_01);
		}else if(viewType == 2){
			presentIconView.setImageResource(R.drawable.icon_chat_money_02);
		}else{
			presentIconView.setImageResource(R.drawable.icon_chat_money_03);
		}
        // until here, deal with send voice msg
		handleTextMessage();
	}

	@Override
    protected void onUpdateView() {
        adapter.notifyDataSetChanged();
    }

    @Override
    protected void onBubbleClick() {
        
    }
}
